package com.bootMybatis.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bootMybatis.dao.MBankMapper;
import com.bootMybatis.service.IXjBankMbankService;
import com.bootMybatis.utils.AjaxJson;
import com.bootMybatis.utils.CreateXjBankFile;

@Service(value = "xjBankMbankService")
@Transactional(readOnly = true)
public class XjBankMbankServiceImpl implements IXjBankMbankService {

	// private static final Log logger = LogFactory.getLog(XjBankServiceImpl.class);

	@Autowired
	private MBankMapper mBankMapper;

	@Override
	public AjaxJson MB_LIMIT_CONFIG() {
		AjaxJson j = new AjaxJson();
		j.setCode("0");
		j.setMsg("生成MB_LIMIT_CONFIG.txt成功");
		try {
			List<Map<String, Object>> list = mBankMapper.MB_LIMIT_CONFIG();
			CreateXjBankFile.INSTANCE.writeFile(list, "MB_LIMIT_CONFIG", "mbank");
		} catch (Exception e) {
			j.setCode("-1");
			j.setMsg(e.getMessage());
			e.printStackTrace();
		}
		return j;
	}

	@Override
	public AjaxJson WB_LIMIT_CONFIG() {
		AjaxJson j = new AjaxJson();
		j.setCode("0");
		j.setMsg("生成WB_LIMIT_CONFIG.txt成功");
		try {
			List<Map<String, Object>> list = mBankMapper.WB_LIMIT_CONFIG();
			CreateXjBankFile.INSTANCE.writeFile(list, "WB_LIMIT_CONFIG", "mbank");
		} catch (Exception e) {
			j.setCode("-1");
			j.setMsg(e.getMessage());
			e.printStackTrace();
		}
		return j;
	}

	@Override
	public AjaxJson MA_CUSTOM_INFO_LOG() {
		AjaxJson j = new AjaxJson();
		j.setCode("0");
		j.setMsg("生成MA_CUSTOM_INFO_LOG.txt成功");
		try {
			List<Map<String, Object>> list = mBankMapper.MA_CUSTOM_INFO_LOG();
			CreateXjBankFile.INSTANCE.writeFile(list, "MA_CUSTOM_INFO_LOG", "mbank");
		} catch (Exception e) {
			j.setCode("-1");
			j.setMsg(e.getMessage());
			e.printStackTrace();
		}
		return j;
	}

	@Override
	public AjaxJson ma_personal_acc() {
		AjaxJson j = new AjaxJson();
		j.setCode("0");
		j.setMsg("生成ma_personal_acc.txt成功");
		try {
			List<Map<String, Object>> list = mBankMapper.ma_personal_acc();
			CreateXjBankFile.INSTANCE.writeFile(list, "ma_personal_acc", "mbank");
		} catch (Exception e) {
			j.setCode("-1");
			j.setMsg(e.getMessage());
			e.printStackTrace();
		}
		return j;
	}

	@Override
	public AjaxJson ma_personal_channel() {
		AjaxJson j = new AjaxJson();
		j.setCode("0");
		j.setMsg("生成ma_personal_channel.txt成功");
		try {
			List<Map<String, Object>> list = mBankMapper.ma_personal_channel();
			CreateXjBankFile.INSTANCE.writeFile(list, "ma_personal_channel", "mbank");
		} catch (Exception e) {
			j.setCode("-1");
			j.setMsg(e.getMessage());
			e.printStackTrace();
		}
		return j;
	}

	@Override
	public AjaxJson t_payee() {
		AjaxJson j = new AjaxJson();
		j.setCode("0");
		j.setMsg("生成t_payee.txt成功");
		try {
			List<Map<String, Object>> list = mBankMapper.t_payee();
			CreateXjBankFile.INSTANCE.writeFile(list, "t_payee", "mbank");
		} catch (Exception e) {
			j.setCode("-1");
			j.setMsg(e.getMessage());
			e.printStackTrace();
		}
		return j;
	}

	@Override
	public AjaxJson MA_WX_NOTICE() {
		AjaxJson j = new AjaxJson();
		j.setCode("0");
		j.setMsg("生成MA_WX_NOTICE.txt成功");
		try {
			List<Map<String, Object>> list = mBankMapper.MA_WX_NOTICE();
			CreateXjBankFile.INSTANCE.writeFile(list, "MA_WX_NOTICE", "mbank");
		} catch (Exception e) {
			j.setCode("-1");
			j.setMsg(e.getMessage());
			e.printStackTrace();
		}
		return j;
	}

	@Override
	public AjaxJson MA_WX_NOTICE_CO() {
		AjaxJson j = new AjaxJson();
		j.setCode("0");
		j.setMsg("生成MA_WX_NOTICE_CO.txt成功");
		try {
			List<Map<String, Object>> list = mBankMapper.MA_WX_NOTICE_CO();
			CreateXjBankFile.INSTANCE.writeFile(list, "MA_WX_NOTICE_CO", "mbank");
		} catch (Exception e) {
			j.setCode("-1");
			j.setMsg(e.getMessage());
			e.printStackTrace();
		}
		return j;
	}
}
